#include "ship.h"

#include <iostream>

#include "module.h"

Ship::Ship(float a, float b):PhysicsObject(){
    Module *basemodule = new Module(1, 1);
    Module *left = new Module(1, 1);
    modules.push_back(basemodule);
    AttachModule(1, 0, left);
}

void Ship::Draw(){
    for(Module* module:modules){
        module->Draw();
    }
}

void Ship::Update(int dt){
    PhysicsObject::Update(dt);
}

bool Ship::AttachModule(int x, int y, Module* newModule){
//    bool hasNeighbour = false;
//    std::vector<Module*> neighbours;
//    std::vector<Direction> neighbourDirections;
//    // Check it's not already occupied
//    for(Module* module:modules){
//        if(module->CheckHullPosition(x, y)==true){
//            std::cout<<"Hull position already occupied\n";
//            return false;
//        }
//        if(module->IsNeighbour(x, y)!=INVALID){
//            hasNeighbour = true;
//            neighbours.push_back(module);
//            neighbourDirections.push_back(module->IsNeighbour(x, y));
//        }
//    }
//
//    if(hasNeighbour==false){
//        std::cout<<"Has no neighbours to attach to\n";
//        return false;
//    }
//
//    modules.push_back(newModule);
//
//    for(unsigned int i=0;i<neighbours.size();i++){
//        neighbours.at(i)->SetNeighbour(neighbourDirections.at(i), neighbours.at(i));
//    }
    return true;
}
